package com.umer.pinban.adapter.user;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.common.ui.recycleview.adapter.RecyclerviewBasicAdapter;
import com.common.ui.recycleview.base.ViewHolder;
import com.common.ui.recycleview.listener.OptListener;
import com.common.utils.Constants;
import com.common.utils.GlideUtils;
import com.umer.pinban.R;
import com.umer.pinban.bean.payMode;
import java.util.List;

public class PayModeAdapter extends RecyclerviewBasicAdapter<payMode> {

    private OptListener optListener;
    private Context context;

    public PayModeAdapter(Context context, List<payMode> datas, int layoutId,
                          OptListener optListener) {
        super(context, datas, layoutId);
        this.optListener = optListener;
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, final payMode bean, final int position) {
        LinearLayout linear_pay = holder.getView(R.id.linear_pay);
        ImageView iv1 = holder.getView(R.id.iv1);
        ImageView iv2 = holder.getView(R.id.iv2);
        TextView tv_txt = holder.getView(R.id.tv_txt);
        tv_txt.setText(bean.getLabel());
        GlideUtils.getInstance().loadImageView(context,
                Constants.IP_PORT_DEFAULT_PICTURE + bean.getIcon(), iv2);
        boolean isSelect = bean.isSelect();
        if(isSelect){
            iv1.setBackgroundResource(R.drawable.select_yes);
        }else {
            iv1.setBackgroundResource(R.drawable.select_no);
        }
        linear_pay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                optListener.onOptClick(v,position);
            }
        });

    }
}
